<?php

class Add_Setup_Password_SavePost
{
    protected $_userId;
    protected $_articleId;
    protected $_savers = array();
    protected $_messager;
    const ARTICLE_RECORD_NOT_FOUND   = 'articleRecordNotFound';
    const ACCESS_DENIED              = 'accessDenied';
    protected $_messageTemplates = array(
        self::ARTICLE_RECORD_NOT_FOUND   => "Article record not found.",
        self::ACCESS_DENIED              => "Access denied.",
    );
    protected $_messages = array();


    public function __construct($articleId)
    {
        $auth = Ext_Auth::getInstance();
        $_userId = $auth->getIdentity();

        $this->_userId             = $_userId;
        $this->_articleId          = $articleId;
        
        $this->_messager = new Ext_Messager($this->_messageTemplates);
    }
    
    public function savePost(Add_Setup_Password_SavePost_Data $data)
    {
        $validater = new Ext_Validate();
        $validater->addValidater(new Add_Setup_Account_SavePost_Validate_OldPassword($this->_data->oldPassword));
        if(!$validater->isValid()){
            $viewResult->addMessages($validater->getMessages());
            $viewResult->setNoRender();
            return "";
        }
        
        $verify = new Ext_User_Verify($data);
        $verifyResult = $verify->verify();
    }
    
    public function addMessage($message)
    {
        $this->_messages[] = $message;
    }
    
    public function addMessages($messages)
    {
        $this->_messages = array_merge($this->_messages, $messages);
    }
    
    public function getMessages()
    {
        return $this->_messages;
    }
    
}
